// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LiveObjectDescriptor.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.LiveObjects
{
    #region Usings

    using System;

    using Org.OpenTrader.Framework.LiveObjects.Interfaces;

    #endregion

    /// <summary>
    /// The live object descriptor.
    /// </summary>
    [Serializable]
    public abstract class LiveObjectDescriptor : ILiveObjectDescriptor
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="LiveObjectDescriptor"/> class. 
        /// t
        /// </summary>
        /// <param name="guid">
        /// </param>
        /// <param name="parentId">
        /// The parentId.
        /// </param>
        /// <param name="interfaceTypeName">
        /// The interfaceTypeName.
        /// </param>
        public LiveObjectDescriptor(Guid guid, Guid parentId, string interfaceTypeName)
        {
            this.InterfaceType = interfaceTypeName;
            this.ID = guid;
            this.ParentID = parentId;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets ConfigurationID.
        /// </summary>
        public Guid ConfigurationID { get; set; }

        /// <summary>
        /// Gets or sets ID.
        /// </summary>
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets InterfaceType.
        /// </summary>
        public string InterfaceType { get; set; }

        /// <summary>
        /// Gets or sets Label.
        /// </summary>
        public string Label { get; set; }

        /// <summary>
        /// Gets or sets Name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets ParentID.
        /// </summary>
        public Guid ParentID { get; set; }

        #endregion

        /// <summary>
        /// The local live object descriptor.
        /// </summary>
        [Serializable]
        public class Local : LiveObjectDescriptor, ILocalLiveObjectDescriptor
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="Local"/> class.
            /// </summary>
            /// <param name="guid">
            /// The guid.
            /// </param>
            /// <param name="parentId">
            /// The parentId.
            /// </param>
            /// <param name="configurationId">
            /// The configurationId.
            /// </param>
            /// <param name="name">
            /// The name.
            /// </param>
            /// <param name="memo">
            /// The memo.
            /// </param>
            /// <param name="interfaceTypeName">
            /// The interfaceTypeName.
            /// </param>
            /// <param name="classTypeName">
            /// The classTypeName.
            /// </param>
            /// <param name="containerId">
            /// The containerId.
            /// </param>
            public Local(
                Guid guid, 
                Guid parentId, 
                Guid configurationId, 
                string name, 
                string memo, 
                string interfaceTypeName, 
                string classTypeName, 
                Guid containerId)
                : base(guid, parentId, interfaceTypeName)
            {
                this.ConfigurationID = configurationId;
                this.ClassType = classTypeName;
                this.ContainerID = containerId;
                this.Name = name;
                this.Label = memo;
            }

            /// <summary>
            /// Initializes a new instance of the <see cref="Local"/> class.
            /// </summary>
            /// <param name="guid">
            /// The guid.
            /// </param>
            /// <param name="parentId">
            /// The parentId.
            /// </param>
            /// <param name="configurationId">
            /// The configurationId.
            /// </param>
            /// <param name="name">
            /// The name.
            /// </param>
            /// <param name="memo">
            /// The memo.
            /// </param>
            /// <param name="interfaceTypeName">
            /// The interfaceTypeName.
            /// </param>
            /// <param name="classTypeName">
            /// The classTypeName.
            /// </param>
            /// <param name="containerId">
            /// The containerId.
            /// </param>
            /// <param name="listenInterface">
            /// The listenInterface.
            /// </param>
            public Local(
                Guid guid, 
                Guid parentId, 
                Guid configurationId, 
                string name, 
                string memo, 
                string interfaceTypeName, 
                string classTypeName, 
                Guid containerId, 
                string listenInterface)
                : base(guid, parentId, interfaceTypeName)
            {
                this.ConfigurationID = configurationId;
                this.ClassType = classTypeName;
                this.ContainerID = containerId;
                this.Name = name;
                this.Label = memo;
                this.ListenURL = listenInterface;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets or sets ClassType.
            /// </summary>
            public string ClassType { get; set; }

            /// <summary>
            /// Gets or sets ContainerID.
            /// </summary>
            public Guid ContainerID { get; set; }

            /// <summary>
            /// Gets or sets ListenURL.
            /// </summary>
            public string ListenURL { get; set; }

            #endregion
        }

        /// <summary>
        /// The remote live object descriptor.
        /// </summary>
        [Serializable]
        public class Remote : LiveObjectDescriptor, IRemoteLiveObjectDescriptor
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="Remote"/> class.
            /// </summary>
            /// <param name="guid">
            /// The guid.
            /// </param>
            /// <param name="parentId">
            /// The parentId.
            /// </param>
            /// <param name="name">
            /// The name.
            /// </param>
            /// <param name="interfaceTypeName">
            /// The interfaceTypeName.
            /// </param>
            /// <param name="url">
            /// The url.
            /// </param>
            public Remote(Guid guid, Guid parentId, string name, string interfaceTypeName, string url)
                : base(guid, parentId, interfaceTypeName)
            {
                this.URL = url;
                this.Name = name;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets or sets URL.
            /// </summary>
            public string URL { get; set; }

            #endregion
        }
    }
}